<template>
  <!-- 金融产品清单 -->
  <div class="layout">
    <div class="financeProduct">
      <div style="display: flex; justify-content: center">
        <Breadcrumb class="breadcrumb" :crumbs="crumbs"></Breadcrumb>
      </div>
      <ProductBox @select="getDetailedPage"></ProductBox>
      <div class="productList">
        <div
          class="item"
          v-for="(item, index) in list"
          :key="index"
          @click="confinanDetail(item.companyFinancingId)"
        >
          <div class="label">
            <template v-if="!item.companyLogo">
              {{ item.firstStr }}
            </template>
            <img v-else :src="item.companyLogo" />
          </div>
          <div class="textBtn">
            {{ get_company_industry_text(item.companyIndustryVal) }}
          </div>
          <div class="content">
            <div class="textBox">
              <div class="textLeft">
                {{ item.financingName || "默认项目" }}
              </div>
              <div class="textRight">
                {{ item.financingIntroduce || "默认简介" }}
              </div>
            </div>
            <div class="textRig">
              <div class="textLeft">
                <div>
                  <span>{{ item.financingMoney }}</span
                  >万
                </div>
                <div>{{ getTurnVal(item.financingTurnVal) }}</div>
              </div>
              <span class="color">{{ item.financingExpect }}</span>
              <!-- <div class="textRight">
                <div><span>{{item.financingExpect}}</span></div>
                
              </div> -->
            </div>
          </div>
        </div>
      </div>
      <div id="policyPagination" v-if="total > 0">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNum"
          background
          :page-sizes="[10, 20, 30, 50]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>
<script>
import { request } from "@/utils/request.js";
import { host } from "@/utils/config.js";
import { getDetailedPage } from "@/common/api/finance";

import Breadcrumb from "@/components/breadcrumb";
import ProductBox from "./components/productBox";
export default {
  data() {
    return {
      name: "finance",
      crumbs: [
        {
          label: "金融服务",
          value: "finance",
        },
        {
          label: "企业融资清单",
          value: "",
          choose: true,
        },
      ],
      types: [],
      turnList: [],
      typeIndex: -1,
      roundIndex: -1,
      list: [],
      pageNum: 1,
      pageSize: 10,
      total: 0,
      company_industry: [],
    };
  },
  components: {
    Breadcrumb,
    ProductBox,
  },
  mounted() {
    this.gettypeList();
    this.getDetailedPage();
  },
  computed: {
    get_company_industry_text() {
      return function (value) {
        const item = this.company_industry.find((e) => e.dictValue == value);
        return item ? item.dictLabel : "";
      };
    },
    getTurnVal() {
      return function (data) {
        let turnList = this.turnList;
        let obj = turnList.find((item) => item.dictValue == data);
        return obj && obj.dictLabel;
      };
    },
  },
  methods: {
    // 字典查询 政策类别
    async gettypeList() {
      // 调用公共方法中的查询字典表
      this.getDictList(
        this,
        `finance_financing_turn,policy_industry_type,company_industry`
      ).then((res) => {
        //  融资的轮次
        this.turnList = res.finance_financing_turn;
        this.types = res.policy_industry_type;
        this.company_industry = res.company_industry;
      });
    },
    // 金融产品清单列表
    async getDetailedPage(data) {
      let param = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        ...data,
      };
      // let api = `${host}/finance/companyFinancing/getDetailedPage`
      let { code, msg, rows, total } = await getDetailedPage(param);
      if (code != "200") return this.$message.warning(msg);
      // console.log('123', res)
      this.total = total;
      this.list = rows;
    },
    /**
     * 改变页面大小事件
     */
    handleSizeChange(e) {
      this.pageSize = e;
      this.getDetailedPage();
    },
    /**
     * 换页事件
     */
    handleCurrentChange(e) {
      this.pageNum = e;
      this.getDetailedPage();
    },
    // 企业金融服务 跳转到指定详情页
    confinanDetail(id) {
      let companyFinancingId = id;
      this.$router.push({
        path: "financeenterpriseDetail",
        query: {
          companyFinancingId,
        },
      });
    },
  },
};
</script>
<style scoped>
.financeProduct {
  width: 1200px;
  margin: 0 auto;
}
.breadcrumb {
  width: 1200px;
  margin: 20px 0;
}
.productBox {
  height: auto;
  border: 1px solid #eeeeee;
  border-bottom: none;
}
.productBox .item {
  border-bottom: 1px solid #eeeeee;
  position: relative;
}
.productBox .item .title {
  width: 168px;
  background: #f1f1f1;
  height: 100%;
  font-size: 14px;
  font-weight: bold;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}
.productBox .item .optionTitleDiv {
  width: 790px;
  margin-left: 188px;
  display: flex;
  font-size: 14px;
  flex-wrap: wrap;
  padding: 10px 0;
}
.productBox .item .optionTitleDiv .allOptionDiv {
  margin-left: 20px;
  width: 44px;
  margin: 5px 10px;
  text-align: center;
  height: 26px;
  line-height: 26px;
  border-radius: 2px;
}
.productBox .item .optionTitleDiv .optionDiv {
  padding: 0px 8px;
  margin: 5px 10px;
  border-radius: 2px;
  height: 26px;
  line-height: 26px;
}
.productBox .item .optionTitleDiv .optionDiv:hover {
  cursor: pointer;
  transition: all 0.2s ease 0s;
}

.productBox .item .optionTitleDiv .optionDivSelected {
  color: #ffffff;
  background-color: #ce0000;
}
.productBox .item .optionTitleDiv .orderOptionDiv {
  display: flex;
  flex-wrap: wrap;
  width: 720px;
}
.productList {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: 50px;
}
.productList .item {
  width: 580px;
  height: 210px;
  border: 1px solid #eeeeee;
  margin-bottom: 20px;
  display: flex;
  padding: 20px;
  cursor: pointer;
  text-align: left;
  position: relative;
}
.productList .item .label {
  width: 80px;
  height: 80px;
  background: #045db9;
  font-size: 41px;
  font-weight: 700;
  line-height: 80px;
  color: #ffffff;
  border-radius: 50%;
  margin-right: 20px;
  flex-shrink: 0;
  text-align: center;
}
.productList .item .label img {
  width: 100%;
  height: 80px;
}
.productList .item .content {
  /* width: 348px; */
  /* display: flex; */
  /* flex-direction: column;
    text-align: left; */
  width: 320px;
}
.productList .item .content .titleBox {
  margin-top: 20px;
  font-size: 14px;
  color: #333;
}
.productList .item .content .textBox {
  display: flex;
  color: #999;
  font-size: 18px;
  flex-direction: column;
  position: relative;
}
.productList .item .content .textBox .textLeft {
  color: #333333;
  font-weight: bold;
  font-size: 24px;
  margin-top: 12px;
  width: 280px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.productList .item .content .textBox .textRight {
  color: #999;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: hidden;
  text-overflow: ellipsis;
  overflow: hidden;
  margin: 10px 0;
}
.productList .item .textBtn {
  background: rgba(0, 113, 229, 0.1);
  color: #0071e5;
  padding: 3px 8px;
  position: absolute;
  right: 0px;
  top: 20px;
  font-size: 14px;
  flex-shrink: 0;
}
.productList .item .content .textRig {
  display: flex;
  color: #999;
  /* justify-content: flex-start; */
  margin-top: 10px;
}
.productList .item .content .textRig .textLeft {
  margin-right: 40px;
  flex-shrink: 0;
}
.productList .item .content .textRig .textLeft div:nth-child(1) {
  font-size: 14px;
  color: #ef6c22;
}
.productList .item .content .textRig .textLeft div:nth-child(1) span {
  font-size: 40px;
  font-weight: bold;
  margin-right: 8px;
}
.productList .item .content .textRig .textLeft div:nth-child(2) {
  font-size: 14px;
  color: #999;
}
.productList .item .content .textRig .textRight {
  /* width: 200px; */
}
.productList .item .content .textRig .color {
  font-size: 18px;
  color: #ef6c22;
  margin-top: 20px;
  font-weight: 700;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.productList .item .content .textRig .textRight div:nth-child(1) span {
  font-size: 18px;
  font-weight: bold;
  margin-right: 8px;
}
.productList .item .content .textRig .textRight div:nth-child(2) {
  font-size: 14px;
  color: #999;
}
.productList .item .btnBox {
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
  border-top: 1px solid #eeeeee;
}
.productList .item .btnBox .btn {
  width: 120px;
  height: 40px;
  line-height: 40px;
  background: #045db9;
  border-radius: 3px;
  color: #ffffff;
  margin-top: 10px;
  margin-right: 20px;
}
#policyPagination {
  text-align: right;
  margin-bottom: 30px;
}
</style>